package Impl;

import jobFactoryItf.CallBack;
import jobFactoryItf.CallBackHelper;
import jobFactoryItf.JobPOA;

public class JobImpl extends JobPOA {
	
	short id;
	CallBack cb;
	
	public JobImpl(short id, CallBack cb) {
		super();
		this.id = id;
		this.cb = cb;
	}
	
	public void faireJob() {
		
		new Thread(new ThreadJob(this)).start();
	}
	
	@Override
	public short getid() {
		return this.id;
	}
}

class ThreadJob implements Runnable {
	JobImpl leJob;
	
	public ThreadJob(JobImpl leJob) {
		this.leJob = leJob;
	}
	
	@Override
	public void run() {
		
		try {
			System.out.println("Youpiii je fait le job " + this.leJob.getid() + " !!!");
			Thread.sleep(3000);
			System.out.println(leJob.cb);
			leJob.cb.finit();
			System.out.println("BOOOOOUH le job " + this.leJob.getid() + " est finit !!!");
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
